package utils

import (
	"fmt"
	"math/rand"
)

var (
	letters = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
)

// GetTestKey 获取指定后缀 key 值，eg: gokv-get-key-000000i
func GetTestKey(i int) []byte {
	s := fmt.Sprintf("%07d", i)
	return []byte("gokv_get_key-" + s)
}

// GetTestValue 获取随机 value 值，后缀长度为 i 个随机字符(a-Z0-9)，eg: gokv_get_value-abc
func GetTestValue(i int) []byte {
	if i <= 0 {
		i = -i
	}
	s := make([]byte, i)
	for j := 0; j < i; j++ {
		s[j] = letters[rand.Intn(len(letters))]
	}
	return []byte("gokv_get_value-" + string(s))
}
